dirName = '../Models/';

modelName = 'Cat';
Errs = {
    'cat1.obj.minL.txt';
    'cat2.obj.minL.txt';
    'cat3.obj.minL.txt';
    'cat4.obj.minL.txt';
    'cat5.obj.minL.txt';
    'cat6.obj.minL.txt';
    'cat7.obj.minL.txt';
    'cat8.obj.minL.txt';
    'cat9.obj.minL.txt';
    'cat10.obj.minL.txt'
    };

%{
modelName = 'Centaur';
Errs = {
    'centaur1.obj.minL.txt';
    'centaur2.obj.minL.txt';
    'centaur3.obj.minL.txt';
    'centaur4.obj.minL.txt';
    'centaur5.obj.minL.txt'
};
%}

n = size(Errs, 1);
dirName = [dirName modelName '/'];

curDir = pwd;
cd(dirName);

thErr = importdata(Errs{1});
thErr = thErr + 1.0;
thErr = nonzeros(thErr) - 1.0;
k = size(thErr, 1);

ErrMatrix = zeros(k, n);
for i = 1 : n
    thErr = importdata(Errs{i});
    thErr = thErr + 1.0;
    thErr = nonzeros(thErr) - 1.0;
    
    ErrMatrix(:, i) = thErr;
end % for

area = sqrt(triMeshArea(vertices, triangles));
ErrMatrix = ErrMatrix / area;

meanErrVect = mean(ErrMatrix, 1);
meanErr = mean(meanErrVect)
maxErrVect = max(ErrMatrix, [], 1);
maxErr = max(maxErrVect)

cd(curDir);

% % % % % % % % % % % % % % % % % % % % % % % % %
%modelId = randi([1, n]);
modelId = 3;
x = 0.0:.01:0.25;
nSamp = size(x, 2);
ModelErr = ErrMatrix(:, modelId);
y = zeros(nSamp, 1);
for i = 1 : nSamp
    y(i) = CorRate(ModelErr, x(i));
end % for
p = plot(x, y);
set(p,'Color','blue','LineWidth',1.1)




